#!/usr/bin/env python

import sys

import gobject
import gtk
import gtk.glade

import dt

class GnomeDT:
    """Esta es una aplicacion Hello World GTK"""
    def __init__(self):
        self.gladefile = "../glade/gnome-dt.glade"
        self.wTree = gtk.glade.XML(self.gladefile)

        self.window = self.wTree.get_widget("window")
        if (self.window):
            self.window.connect("destroy", gtk.main_quit)
        self.window.show ();

	self.dt = dt.DT ("/home/jcvallejo/tareas/")
	self.dt.update ()

	view = self.wTree.get_widget("ilist")
	view.set_headers_visible(True)

 	rend = gtk.CellRendererText ()
    	col = gtk.TreeViewColumn("Status", rend, text=0)
    	col.set_cell_data_func(rend, self.render_cell, 'Status')
    	view.append_column(col)
	
	rend = gtk.CellRendererText ()
	col = gtk.TreeViewColumn ("Owner", rend, text=0)
    	col.set_cell_data_func(rend, self.render_cell, 'Owned-by')
	view.append_column(col)
    
    	rend = gtk.CellRendererText ()
    	col = gtk.TreeViewColumn ("Version", rend, text=0)
    	col.set_cell_data_func(rend, self.render_cell, 'Reported-for')
    	view.append_column(col)
    
    	rend = gtk.CellRendererText ()
    	col = gtk.TreeViewColumn ("Category", rend, text=0)
    	col.set_cell_data_func(rend, self.render_cell, 'Category')
    	view.append_column(col)

    	rend = gtk.CellRendererText ()
    	col = gtk.TreeViewColumn ("Title", rend, text=0)
    	col.set_cell_data_func(rend, self.render_cell, 'Title')
    	view.append_column(col)


	view.set_model (self.dt.get_list ())

    def render_cell (self, column, cell, model, itera, user_data):
	issue = model.get_value(itera, 0)
	cell.set_property("text", issue.get (user_data))

if __name__ == "__main__":
    gdt = GnomeDT()
    gtk.main()
 
